<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model as BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

class AttachmentModel extends BaseModel
{
    use HasFactory, SoftDeletes;

    protected $table = 't_attachment';

    protected $primaryKey = 'id';

    public $timestamps = true;

    const CREATED_AT = 'created_at';
    
    const UPDATED_AT = null;

    protected $guarded = [];

    protected $hidden = [
        'deleted_at',
    ];

    //类型 1全部 2流程库 3资料库 4成本库
    const TYPE_ALL = 1;   //全部
    const TYPE_PROCESS = 2;  //流程库
    const TYPE_DATA = 3;  //资料库
    const TYPE_COST = 4;  //成本库
    const TYPE_MAPS = [
        self::TYPE_ALL => '全部',
        self::TYPE_PROCESS => '流程库',
        self::TYPE_DATA => '资料库',
        self::TYPE_COST => '成本库',
    ];

    //创建人
    public function create_admin(): BelongsTo {
        return $this->belongsTo(AdminModel::class, 'created_admin_id');
    }

}
